<?php

/*

Sales Log (sales_log.php)

*/

$page_title = "Sales Log";
$rank_check = 1;
include "header.inc.php";

print "$openHTML";

$find_shop = fetch("SELECT * FROM usershops2 WHERE owner = '$userid' AND game = '$game'");

if (!$find_shop[id])
{
	die("You do not have a shop yet, please click <a href=makeshop.php?game=$game>here</a> to create one.$closeHTML");
}

ECHO <<<END

<p align=center><a href=myshop.php?game=$game>My Stock</a> | <a href=edit_shop.php?game=$game>Edit Shop</a> | <a href=usershop.php?game=$game&user=$username>View Shop</a> | <a href=upgrade_shop.php?game=$game>Upgrade Shop</a> | <a href=sales_log.php?game=$game>Sales Log</a></p>

<P align=center><TABLE BGCOLOR="$tableOutline" CELLSPACING=1 CELLPADDING=0 WIDTH=450>
   <TR BGCOLOR="$topAndBottomBG">
      <TD COLSPAN=3 HEIGHT=45>
         <CENTER><FONT SIZE="+3" COLOR="$topAndBottomText"><B>--Sales
         Logs--</B></FONT></CENTER>
      </TD>
   </TR>
   <TR BGCOLOR="$maincellColor">
      <TD>
         <CENTER>Item Name</CENTER>
      </TD>
      <TD>
         <CENTER>Bought By</CENTER>
      </TD>
      <TD>
         <CENTER>Bought For</CENTER>
      </TD>
   </TR>
END;

$findLogs = mysql_query("SELECT * FROM sales_logs2 WHERE bought_from = '$userid' AND game = '$game'");
while ($getLogs = mysql_fetch_array($findLogs))
{
	$findItem = fetch("SELECT item_name FROM items2 WHERE id = '$getLogs[bought_item]' AND game = '$game'");
	$findBuyer = fetch("SELECT display_name FROM members2 WHERE id = '$getLogs[bought_by]' AND game = '$game'");
	$cellcolor = alternate($cellcolor,"$reallyLight","$maincellColor");

	print "   <TR BGCOLOR=\"$cellcolor\"> <TD> <CENTER>$findItem[item_name]</CENTER> </TD> <TD>
	<CENTER>$findBuyer[display_name]</CENTER> </TD> <TD> <CENTER>$getLogs[bought_price]</CENTER> </TD> </TR>
	";
}


print "</TABLE></P>";

print "<p align=center><a href=sales_log.pro.php?game=$game>Delete Sales Log</a></p>";

print "$closeHTML";
?>